import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:ljy_p_app/diffwidget/never_overscroll_indicator.dart';
import 'package:ljy_p_app/model/common_list_datatype.dart';

class NavigatorUtils {
  ///弹出 dialog
  static Future<T?> showLJYDialog<T>(
      {required BuildContext context,
      bool barrierDismissible = true,
      required WidgetBuilder builder}) {
    return showDialog<T>(
        context: context,
        barrierDismissible: barrierDismissible,
        builder: (context) {
          return MediaQuery(
              data: MediaQueryData.fromView(
                      WidgetsBinding.instance.platformDispatcher.views.first)
                  .copyWith(textScaler: TextScaler.noScaling),
              child: NeverOverscrollIndicator(
                  needOverload: false,
                  child: SafeArea(child: builder(context))));
        });
  }

  /// 通用列表
  static gotoCommonList(BuildContext context, String? title, String showType, CommonListDatatype dataType, {String? userName, String? reposName}) {
    Get.toNamed('/history', arguments: {
      'title': title,
      'showType': showType,
      'dataType': dataType,
      'userName': userName,
      'reposName': reposName
    });
  }

  /// 个人中心
  static gotoUserProfileInfo(BuildContext context) {
    Get.toNamed('/profileInfo');
  }

  /// 公共打开方式
  static NavigatorRouter(BuildContext context, Widget Widget) {
    
  }

  ///Page页面的容器，做一次通用自定义
  static Widget pageContainer(widget, BuildContext context) {
    return MediaQuery(
      ///不受系统字体缩放影响
      data: MediaQuery.of(context).copyWith(textScaler: TextScaler.noScaling),
      child: NeverOverscrollIndicator(
        needOverload: false,
        child: widget,
      ));
  }
}
